package com.wintrue.ffxs.ui.mine.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.wintrue.ffxs.R;
import com.wintrue.ffxs.base.adapter.CommonBaseAdapter;
import com.wintrue.ffxs.utils.ImageUtil;
import com.wintrue.ffxs.utils.Util;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by lhe on 2017/8/23.
 */

public class MyOrderListAdapter extends CommonBaseAdapter<String>{

    private Activity activity;

    public MyOrderListAdapter(Activity activity) {
        super(activity);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = mLayoutInflater.inflate(R.layout.adapter_order_list_item,null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        String url = "http://ww3.sinaimg.cn/large/610dc034jw1f6m4aj83g9j20zk1hcww3.jpg";
        holder.count.setText("4");
        holder.weight.setText("5.33吨");
        holder.price.setText(Util.formatMoneyNoUnitTwo(6000.33));
        ImageUtil.displayImage(url,holder.imageView1);
        ImageUtil.displayImage(url,holder.imageView2);
        ImageUtil.displayImage(url,holder.imageView3);
        ImageUtil.displayImage(url,holder.imageView4);
        holder.daiwanchengView.setVisibility(View.GONE);
        holder.yiwanchengView.setVisibility(View.GONE);
        holder.closedView.setVisibility(View.GONE);
        switch (position%3){
            case 0:
                holder.daiwanchengView.setVisibility(View.VISIBLE);
                break;
            case 1:
                holder.yiwanchengView.setVisibility(View.VISIBLE);
                break;
            case 2:
                holder.closedView.setVisibility(View.VISIBLE);
                break;
        }
        holder.dingdangenzong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {//订单跟踪

            }
        });
        holder.shenqingfahuo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {//申请发货

            }
        });
        holder.querenshouhuo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {//确认收货

            }
        });
        return convertView;
    }

    class ViewHolder{
        @Bind(R.id.order_list_item_count)
        TextView count;
        @Bind(R.id.order_list_item_weight)
        TextView weight;
        @Bind(R.id.order_list_item_price)
        TextView price;
        @Bind(R.id.order_list_item_img1)
        ImageView imageView1;
        @Bind(R.id.order_list_item_img2)
        ImageView imageView2;
        @Bind(R.id.order_list_item_img3)
        ImageView imageView3;
        @Bind(R.id.order_list_item_img4)
        ImageView imageView4;
        @Bind(R.id.order_list_item_daiwancheng_ll)
        View daiwanchengView;
        @Bind(R.id.order_list_item_daiwancheng_genzong)
        TextView dingdangenzong;
        @Bind(R.id.order_list_item_daiwancheng_apply)
        TextView shenqingfahuo;
        @Bind(R.id.order_list_item_yiwancheng_ll)
        View yiwanchengView;
        @Bind(R.id.order_list_item_yiwancheng_querenshouhuo)
        TextView querenshouhuo;
        @Bind(R.id.order_list_item_closed_ll)
        View closedView;

        ViewHolder(View view){
            ButterKnife.bind(this,view);
        }
    }
}
